package com.example.consumptionrecords.mapper;

import com.example.consumptionrecords.entity.dto.ConRecordsDTO;
import com.example.consumptionrecords.entity.vo.ConRecordsStatisticsVO;
import com.example.consumptionrecords.entity.pojo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * SunJingxuan
 * 2022 \ 07 \ 29
 */
@Mapper
public interface HomeMapper {

	/**
	 * 首页卡片数据
	 * @return
	 */
    List<HomeCard> selectHomeCard();

	/**
	 * 消费记录按照时间段统计
	 * @param startDate 开始时间
	 * @param endDate 结束时间
	 * @param userId 用户id
	 * @return 消费记录统计数据
	 */
    List<ConRecordsStatisticsVO> selectConRecordsStatistics(@Param(value = "startDate")String startDate,
															@Param(value = "endDate")String endDate,
															@Param(value = "userId")Integer userId);

	/**
	 * 支付渠道
	 * @return 支付渠道
	 */
    @ResultMap("channel")
    @Select("SELECT id, pay_channel_name, pay_channel_dark_icon, pay_channel_light_icon FROM con_pay_channel WHERE delete_status = 0")
    List<ConPayChannel> selectConPayChannel();

	/**
	 * 消费平台
	 * @return 消费平台
	 */
    @ResultMap("platform")
    @Select("SELECT id, pay_platform_name, pay_platform_dark_icon, pay_platform_light_icon FROM con_platform WHERE delete_status = 0")
    List<ConPlatform> selectConPlatform();

	/**
	 * 消费类型
	 * @return 消费类型
	 */
    @ResultMap("conType")
    @Select("SELECT id, type_name, type_dark_icon, type_light_icon FROM con_type WHERE delete_status = 0")
    List<ConType> selectConType();

	/**
	 * 添加消费记录
	 * @param conRecordsDTO 消费记录
	 * @param userId 用户id
	 */
    void insertConRecords(@Param(value = "conRecorde") ConRecordsDTO conRecordsDTO, @Param("userId")Integer userId);
}
